#ifndef xpack_test_math_ln
#define xpack_test_math_ln
#pragma push_macro("xuser")
#undef  xuser
#define xuser mixc::test_math_ln::inc
#include"test/helper.hpp" // 需要放第一
#include"define/nan.hpp"
#include"math/literal.hpp"
#include"math/ln.hpp"
#include"math/random.hpp"
#include<math.h>
#pragma pop_macro("xuser")

namespace mixc::test_math_ln{
    namespace inc{
        using namespace literal;
    }

    xtest("ln"){
        f64 expect      = {};
        f64 actually    = {};
        f64 v           = 1.0;

        // 非规格浮点数
        expect          = log(0.6566876194613209e-308);
        actually        = inc::ln(0.6566876194613209e-308);
        xassert_fe(expect, actually);

        v               = 1.0;

        for(ixx i = 0; i < 2048; i++, v *= 1.2){
            expect      = ::log(v);
            actually    = inc::ln(v);
            xassert_fe(expect, actually, v, i);
        }

        for(ixx i = 0; i < 16 * 1024; i++){
            while((v = inc::random<f64>()) <= 0);

            expect      = ::log(v);
            actually    = inc::ln(v);
            xassert_fe(expect, actually, v, i);
        }
    };
}

#endif
